import os
import time
from multiprocessing import Process


def func():
    print(f"子进程")
    time.sleep(3)


if __name__ == '__main__':
    print(f"主进程的pid={os.getpid()}")
    p = Process(target=func)
    print(p.is_alive())  # False
    p.start()  # 异步非阻塞
    print(p.is_alive())  # True
    p.terminate()  # 异步非阻塞
    print(p.is_alive())  # False
    time.sleep(1)
    print(p.is_alive())  # False
